package com.example.tomcat.config;

import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TomcatConfiguration{

    @Bean
    public WebServerFactoryCustomizer webServerFactoryCustomizer(){

        return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>(){

            /**
             * 定制嵌入式Servlet容器的相关设置
             * @param factory
             */
            @Override
            public void customize(ConfigurableWebServerFactory factory) {
               factory.setPort(9999);
            }
        };
    }
}
